<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">

		<title>w0925_2_object</title>

	</head>

	<body>
		<p id="i1"></p>
		<script>
			/*객체------------------
			 객체(object-속성,기능)
			 document.write("<pre>");
			 document.write("</pre>")*/
			/*	var(객체)변수명={
			 속성1:number,
			 속성2:string,
			 속성3:boolean,
			 속성4:array,
			 메소드:function(){함수 실행코드}
			 }*/

			var person = {
				name : "이순신",
				age : 49,
				isman : true,
				eat : function(food) {
					//함수실행코드
					alert('person이 먹은 음식은'+food);
				}
			};
			var text = "";
		for(var x in person){
			text+=person[x]+"<br/>";
		}
		
		document.getElementById("i1").innerHTML=text;	
		
			person.eat("삼겹살에 소주?");
			
			
			var student = {};

			//객체 속성 추가
			//객체명[keyname] 객체명.keyname
			student.이름 = "현빈";
			student.취미 = "악기";
			student.특기 = "연기";

			student.toString = function() {
				var text = "";
				for(var x in this) {
					text += this[x]+"<br/>";
				}
				return text;
			};
			
			//객체명.메소드명			
			document.getElementById("i1").innerHTML=student.toString();
		</script>
	</body>
</html>
